#include <bits/stdc++.h>

using namespace std;

int main_135()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    vector<int> adjL[n];
    for (int i=0;i<m ;++i )
    {
        scanf("%d%d",&u,&v);
        adjL[u].push_back(v);
    }
    for (int i=0;i<n ;++i )
    {
        printf("%d(%d)",i,adjL[i].size());
        for (int j=0;j<adjL[i].size() ;++j )
        {
            printf(" %d",adjL[i][j]);
        }
        printf("\n");
    }
    return 0;
}
